package handler

import (
	"gin/api/request"
	"gin/global/model"
	classtype "gin/srv"
	"net/http"

	"github.com/gin-gonic/gin"
)

func ClassTypeIndex(context *gin.Context) {
	var C request.ClassTypeIndex
	if err := context.ShouldBind(&C); err != nil {
		context.JSON(http.StatusOK, gin.H{"data": nil, "msg": err.Error()})
		return
	}
	index, err := model.ClassTypeConn.ClassTypeIndex(model.Ctx, &classtype.ClassTypeIndexRequest{
		Name: C.Name,
	})
	if err != nil {
		context.JSON(http.StatusOK, gin.H{"data": nil, "msg": err.Error()})
		return
	}
	context.JSON(http.StatusOK, gin.H{"data": index, "msg": nil})
}
